home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / PERL.SPK / Perl5001 / Perl < prev    next >
Text File  |  1992-09-11  |  56KB  |  1,925 lines

  1. A P Oliver
  2. 11 Sept 92
  3. This file is in the public domain.
  4. Please notify aoliver@acorn.co.uk
  5. of any errors or omissions.
  6.  
  7. %accept
  8.    Not implemented under RISC OS
  9.    
  10. %alarm
  11.    Not implemented under RISC OS
  12.    
  13. %bind
  14.    Not implemented under RISC OS
  15.    
  16. %binmode
  17.    Not implemented under RISC OS
  18.    
  19. %chmod
  20.    Not implemented under RISC OS
  21.    
  22. %chown
  23.    Not implemented under RISC OS
  24.    
  25. %chroot
  26.    Not implemented under RISC OS
  27.    
  28. %connect
  29.    Not implemented under RISC OS
  30.    
  31. %crypt
  32.    Not implemented under RISC OS
  33.    
  34. %dump
  35.    Not implemented under RISC OS
  36.    
  37. %fcntl
  38.    Not implemented under RISC OS
  39.    
  40. %fileno
  41.    Not implemented under RISC OS
  42.    
  43. %flock
  44.    Not implemented under RISC OS
  45.    
  46. %fork
  47.    Not implemented under RISC OS
  48.    
  49. %getgrent
  50.    Not implemented under RISC OS
  51.    
  52. %setgrent
  53.    Not implemented under RISC OS
  54.    
  55. %endgrent
  56.    Not implemented under RISC OS
  57.    
  58. %getgrgid
  59.    Not implemented under RISC OS
  60.    
  61. %getgrnam
  62.    Not implemented under RISC OS
  63.    
  64. %gethostbyaddr
  65.    Not implemented under RISC OS
  66.    
  67. %gethostbyname
  68.    Not implemented under RISC OS
  69.    
  70. %gethostent
  71.    Not implemented under RISC OS
  72.    
  73. %getlogin
  74.    Not implemented under RISC OS
  75.    
  76. %getnetbyaddr
  77.    Not implemented under RISC OS
  78.    
  79. %getnetbyname
  80.    Not implemented under RISC OS
  81.    
  82. %getnetent
  83.    Not implemented under RISC OS
  84.    
  85. %getpeername
  86.    Not implemented under RISC OS
  87.    
  88. %getpgrp
  89.    Not implemented under RISC OS
  90.    
  91. %getppid
  92.    Not implemented under RISC OS
  93.    
  94. %getpriority
  95.    Not implemented under RISC OS
  96.    
  97. %getprotobyname
  98.    Not implemented under RISC OS
  99.    
  100. %getprotobynumber
  101.    Not implemented under RISC OS
  102.    
  103. %getprotoent
  104.    Not implemented under RISC OS
  105.    
  106. %getpwent
  107.    Not implemented under RISC OS
  108.    
  109. %getpwnam
  110.    Not implemented under RISC OS
  111.    
  112. %getpwuid
  113.    Not implemented under RISC OS
  114.    
  115. %getservbyname
  116.    Not implemented under RISC OS
  117.    
  118. %getservbyport
  119.    Not implemented under RISC OS
  120.    
  121. %getservent
  122.    Not implemented under RISC OS
  123.    
  124. %getsockname
  125.    Not implemented under RISC OS
  126.    
  127. %getsockopt
  128.    Not implemented under RISC OS
  129.    
  130. %ioctl
  131.    Not implemented under RISC OS
  132.    
  133. %semctl
  134.    Not implemented under RISC OS
  135.    
  136. %semget
  137.    Not implemented under RISC OS
  138.    
  139. %semop
  140.    Not implemented under RISC OS
  141.    
  142. %send
  143.    Not implemented under RISC OS
  144.    
  145. %setgrp
  146.    Not implemented under RISC OS
  147.    
  148. %setpriority
  149.    Not implemented under RISC OS
  150.    
  151. %setsockopt
  152.    Not implemented under RISC OS
  153.    
  154. %shmctl
  155.    Not implemented under RISC OS
  156.    
  157. %shmget
  158.    Not implemented under RISC OS
  159.    
  160. %shmread
  161.    Not implemented under RISC OS
  162.    
  163. %shmwrite
  164.    Not implemented under RISC OS
  165.    
  166. %shutdown
  167.    Not implemented under RISC OS
  168.    
  169. %socket
  170.    Not implemented under RISC OS
  171.    
  172. %socketpair
  173.    Not implemented under RISC OS
  174.    
  175. %symlink
  176.    Not implemented under RISC OS
  177.    
  178. %sysread
  179.    Not implemented under RISC OS
  180.    
  181. %syswrite
  182.    Not implemented under RISC OS
  183.    
  184. %times
  185.    Not implemented under RISC OS
  186.    
  187. %umask
  188.    Not implemented under RISC OS
  189.    
  190. %utime
  191.    Not implemented under RISC OS
  192.    
  193. %wait
  194.    Not implemented under RISC OS
  195.    
  196. %waitpid
  197.    Not implemented under RISC OS
  198.    
  199. %atan2(X,Y)
  200.    returns arctangent X/Y in the range -pi to +pi
  201.    
  202. %caller
  203. caller(EXPR) 
  204. caller EXPR
  205.    caller returns stack frame
  206.    information as:-
  207.     
  208.    ($package, $filename, $line) = caller
  209.     
  210.    EXPR (if present) is number of stack 
  211.    frames  to rise through
  212.    
  213. %chdir
  214.    chdir(EXPR)
  215.    chdir EXPR
  216.    chdir
  217.    changes CSD to EXPR if possible.
  218.    With no parameter changes to root of
  219.    default drive.
  220.    Returns 1 for succes or 0 for failure.
  221.    
  222. %chop
  223.    chop(LIST)
  224.    chop(VARIABLE)
  225.    chop VARIABLE
  226.    chop
  227.    chops the last character from a string and returns the
  228.    character removed.
  229.    With no variable chops $_.
  230.    Given a list chops each item of the list and returns
  231.    the (former) last character of the last item.
  232.    Lvalues may be chopped:- 
  233.    $answer=chop(<STDIN>);
  234.    
  235. %close
  236.    close(FILEHANDLE)
  237.    close FILEHANDLE
  238.    closes a file or pipe and resets the line counter ($.)
  239.    Closing a pipe waits for the pipe to exit and sets $?.
  240.    FILEHANDLE may be an expression evaluating to
  241.    a real filehandle name.
  242.    
  243. %closedir
  244.    closedir(DIRHANDLE)
  245.    closedir DIRHANDLE
  246.    closes a directory opened by opendir 
  247.    
  248. %cos
  249.    cos(EXPR)
  250.    cos EXPR
  251.    returns cosine of EXPR (taken as radians)
  252.    
  253. %dbmclose
  254.    dbmclose(ASSOC_ARRAY)
  255.    dbmclose ASSOC_ARRAY
  256.    breaks the binding between a dbm file and 
  257.    an associative array
  258.    
  259. %dbmopen
  260.    dbmopen(ASSOC_ARRAY,DBNAME,MODE)
  261.    binds ASSOC_ARRAY to dbm file called DBMNAME
  262.    uses GNU dbm package and is believed to be 
  263.    rather slow.
  264.    
  265. %defined
  266.    defined(EXPR)
  267.    defined EXPR
  268.    EXPR is an lvalue thus
  269.     
  270.    print "$val\n" while defined($val = pop(@ary));
  271.     
  272.    is perfectly valid;
  273.    returns 1 if EXPR has a defined value, 0 otherwise
  274.     
  275.    packages may be checked for
  276.     
  277.    die "No XYZ" unless defined %_XYZ;
  278.     
  279.    
  280. %delete
  281.    delete $ASSOC{KEY}
  282.    deletes the specified value from the specified
  283.    associative array.
  284.    If the array is bound to a dbm file then deletes
  285.    the corresponding entry.
  286.    
  287. %die
  288. die(LIST)
  289. die LIST
  290. die
  291.    i) Outside an eval
  292.    prints the concatenated LIST to STDERR and exits
  293.    with the current value of $! unless $! is 0 in
  294.    which case ($? >> 8) is used to allow for
  295.    `commands`.
  296.    With no LIST uses "Died".
  297.    If the LIST does not have a terminal newline
  298.    the die function appends the script filename, 
  299.    line number, and input line number (if any), with a 
  300.    newline.
  301.    ii) Within an eval
  302.    as above except that the $@ variable contains the
  303.    string that would have been output on STDERR, the
  304.    eval is  aborted and itself returns the undefined
  305.    value. 
  306.    
  307. %do
  308. do BLOCK 
  309. do SUBROUTINE(LIST) 
  310. do EXPR
  311.    i) The do BLOCK form returns the value of the last
  312.    command in the enclosed sequence. When modified by 
  313.    a loop modifier, e.g.
  314.    
  315.         do { ... } unless CONDITION
  316.    
  317.    the BLOCK is executed at least once before the
  318.    CONDITION is tested.
  319.     
  320.    ii) The do SUBROUTINE(LIST) is a subroutine
  321.    invocation. The brackets are essential (even with an
  322.    empty list) to disambiguate this from the do EXPR
  323.    form. SUBROUTINE may be a simple scalar variable
  324.    containing the name of a  subroutine to call. The
  325.    arguments are always evaluated in an array context.
  326.    The alternative (and generally recommended) form is
  327.     
  328.    &SUBROUTINE(LIST)
  329.     
  330.    in this form the parentheses are optional if the
  331.    list is  empty in which case the @_ array is not
  332.    passed to the  subroutine.
  333.     
  334.    iii) The do EXPR form should be considered as an 
  335.    obsolescent version of the requires operator which 
  336.    should be preferred in new code.
  337.    
  338. %each
  339. each(ASSOC_ARRAY)
  340. each ASSOC_ARRAY
  341.    returns a two element list, ($key,$value), formed
  342.    from  the next value of the associative array. On
  343.    exhausting the associative array returns a null
  344.    array before starting again on the next call. The
  345.    iterator can be reset only by reading all of the
  346.    elements and the array must not be modified while
  347.    iterating over it. The iterator is shared with the
  348.    keys() and values() functions for any given
  349.    associative array. Is not too clever in Perl v3.0
  350.    and should not be pushed too hard. 
  351.    
  352. %eof
  353. eof(FILEHANDLE)
  354. eof()
  355. eof
  356.    Returns 1 if the next read on FILEHANDLE will
  357.    return eof or if the file is closed. Uses ungetc so
  358.    is useless in an interactive context. A bare eof
  359.    refers to the last file read (and therefore
  360.    distinguishes individual files within the @ARGV
  361.    pseudo file. eof() on the other hand would return
  362.    true only for the last file in the @ARGV stream.
  363.    
  364. %eval
  365. eval(EXPR) 
  366. eval EXPR 
  367. eval 
  368.    The value returned by EXPR is parsed and executed as
  369.    a perl program within the context of the current
  370.    program. The eval text is a block so variables may
  371.    be localised. Eval returns the undefined value if
  372.    there were any syntax or runtime errors with the
  373.    error string in $@. Otherwise a null string is
  374.    guaranteed to be returned in $@ with the eval
  375.    returning the value of the last  expression
  376.    evaluated. $_ will be evaluated if no parameter is
  377.    given. The parameter itself does not need to contain
  378.    a terminal semicolon. A simple perl shell is formed
  379.    by
  380.     
  381.    while (<>) { eval; print $@; }
  382.    
  383. %exec
  384. exec(LIST)
  385. exec LIST
  386.    replaces the current perl program with the program
  387.    specified in list. Therefore exec never normally
  388.    returns. If it does it returns false and $! should
  389.    be checked for an indication of what went wrong.
  390.    Note that exec does not flush any buffers so the
  391.    value of $| may need to be adjusted to avoid lost
  392.    output. 
  393.    
  394. %exit
  395. exit(EXPR) 
  396. exit EXPR 
  397.    Exits immediately with the specified value. Note
  398.    that exit cannot be trapped, therefore die is better
  399.    used within subroutines. 
  400.    
  401. %exp
  402. exp(EXPR) 
  403. exp EXPR
  404.    Returns e to the power of EXPR. 
  405.    
  406. %format
  407. format NAME = 
  408. FORMLIST
  409. .
  410.  
  411.    If NAME is omitted it default to STDOUT
  412.    FORMLIST is a sequence of lines.
  413.     
  414.    Lines beginning with '#' are treated as comments.
  415.     
  416.    Other lines are picture lines that print literally 
  417.    apart from picture fields as described below, or
  418.    argument lines containing lists of names of variables 
  419.    whose values will be inserted into the previous
  420.    picture line.
  421.     
  422.    Picture fields are:
  423.     
  424.    @<<<<<<         left justified field 
  425.    @>>>>           right justified field
  426.    @|||||||        centred field
  427.    @###.##         numeric field, point justified
  428.    @*              a multi-line field (should be alone
  429.                    on a line)
  430.  
  431.    Picture fields may start with ^ instead of @ in which
  432.    case the variable is 'shifted' by the amount 
  433.    actually used and the remainder is available next
  434.    time the variable is referenced. This allows block
  435.    filling at the expense of destroying the original
  436.    contents of the variable. The string '...' may be used
  437.    for the final line of the block in which case '...'
  438.    will appear on the output if the variable didn't fit. 
  439.    Blank lines may be supressed by putting a '~' anywhere
  440.    in the line.
  441.  
  442.    Example:
  443.  
  444. format =
  445. Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  446.          $subject
  447. Index: @<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<
  448. #
  449. ## $DESCRIPTION WILL BE DESTROYED
  450. #
  451.        $index,                    $description
  452. Priority: @<<<<<<<<< Date: @<<<<< ^<<<<<<<<<<<<<<<<<<
  453.           $priority,       $date,  $description
  454. From: @<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<
  455.       $from,                      $description
  456. Assigned to: @<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<
  457.              $programmer,         $description
  458. ~                                 ^<<<<<<<<<<<<<<<...
  459.                                   $description
  460. .
  461.  
  462. %getc
  463. getc(FILEHANDLE) 
  464. getc FILEHANDLE 
  465. getc 
  466.    returns the next character from the file attached to
  467.    the filehandle or STDIN if none. Returns a null
  468.    string at eof. Very slow, probably only useful in
  469.    interactive contexts. 
  470.    
  471. %gmtime
  472. gmtime(EXPR) 
  473. gmtime
  474.    EXPR gmtime returns a nine element list. Typically
  475.    used as
  476.     
  477.    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
  478.            =gmtime(time);
  479.       
  480.    note that most of the arrays are zero based. if EXPR
  481.    is omitted a£the value returned is as for
  482.    gmtime(time).
  483.     
  484.    Under RISC OS 3 the value returned is as contained
  485.    in Sys$Time and the $isdst element is zero, so the
  486.    time may be BST or GMT.
  487.     
  488.    /*      There must be a better way of getting at
  489.            this than
  490.     
  491.    do { open(T,"status|"); local(@T)=<T>; grep(/BST/,@T); }
  492.     
  493.    which bit of the CMOS do we read?
  494.    where are my RISC OS 3 PRMs??
  495.    */
  496.    
  497. %goto
  498. goto LABEL
  499.    Although a function this does not return a value.
  500.    The LABEL must be on a statement in the main body
  501.    that is not inside a do {} construct. Present only
  502.    for backward compatibility.
  503.    
  504. %grep
  505. grep(EXPR,LIST)
  506.    Evaluates EXPR for each element of LISt and returns
  507.    a new list constructed of those elements of LIST for
  508.    which EXPR evaluated true. Inside the EXPR, $_
  509.    contains the LIST element being considered.
  510.    Modifying $_ is supported, but will have
  511.    unpredictable results if LIST is not a named array.
  512.    If evaluated in a scalar context returns the number
  513.    of times that EXPR evaluated true. EXPR may, of
  514.    course, be an arbitrarily long 'do {BLOCK}'.
  515.    
  516. %hex
  517. hex(EXPR)
  518. hex EXPR
  519.    returns the decimal value of EXPR treated as a hex
  520.    string. Use oct for strings that might start 0 or
  521.    0x. Spintf can be used for the reverse,
  522.     
  523.    $number=hex("ffff12c0"), sprintf("%lx",$number) 
  524.    
  525. %index
  526. index(STR,SUBSTR,OFFSET)
  527. index(STR,SUBSTR)
  528.    Returns the position of the first occurence of
  529.    SUBSTR in STR. If OFFSET is specified, searching
  530.    commences there. OFFSETs run from 0 unless $[ is
  531.    altered. If SUBSTR is not found, $[-1 is returned,
  532.    usually -1.
  533.    
  534. %int
  535. int(EXPR)
  536. int EXPR
  537.    Returns the integer portion of EXPR.
  538.    
  539. %join
  540. join(EXPR,LIST)
  541.    Returns a string formed by joining the separate
  542.    strings of LIST into a single string with fields
  543.    separated by the value of EXPR.
  544.    
  545. %keys
  546. keys(ASSOC_ARRAY)
  547. keys ASSOC_ARRAY
  548.    Returns a normal array containing all the keys of
  549.    the associative array. With associative arrays bound
  550.    to dbm files the resulting array could be very
  551.    large, in which case the use of 'each' and handling
  552.    the keys one at a time might be preferable.
  553.    
  554. %kill
  555. kill EXPR
  556.    Raises the signal represented by EXPR (which should
  557.    evaluate to an integer or a signal name). Signals
  558.    are:-
  559.     
  560.      ABRT 1   /* abort */
  561.      FPE  2   /* arithmetic exception  */
  562.      ILL  3   /* illegal instruction   */
  563.      INT  4   /* attention request from user   */
  564.      SEGV 5   /* bad memory access     */
  565.      TERM 6   /* termination request   */
  566.      STAK 7   /* stack overflow*/
  567.      USR1 8
  568.      USR2 9
  569.      SERROR 10
  570.          
  571.    Only SIGINT (Escape) is likely to be worth raising
  572.    or trapping
  573.    
  574. %length
  575. length(EXPR)
  576. length EXPR
  577.    returns the length in characters of EXPR
  578.    
  579. %local
  580. local(LIST)
  581.    LIST must be composed of legal lvalues. The elements
  582.    of LIST are then declared to be local to the
  583.    enclosing block, subroutine, eval, or require. The
  584.    LIST may be assigned if desired: a common idiom for
  585.    naming parameters to sub-routines (and changing
  586.    call-by-reference to call-by-value at the same time.
  587.     
  588.    local($min,$max) = @_
  589.    
  590. %localtime
  591. localtime(EXPR)
  592.    similar to gmtime, but supposed to return a time
  593.    corrected for the local time zone. Unlikely to be
  594.    any different under RISC OS.
  595.     
  596.    
  597. %log
  598. log(EXPR)
  599. log EXPR
  600.    returns log base e of EXPR
  601.    
  602. %lstat
  603.    lstat(FILEHANDLE)
  604.    lstat FILEHANDLE
  605.    lstat EXPR
  606.    should return the same value as stat on a system
  607.    without symbolic links.  However, appears to be
  608.    undefined in this port.
  609.    
  610. %mkdir
  611. mkdir(FILENAME)
  612. mkdir FILENAME
  613.    creates a directory with the specified name. Returns
  614.    1 for success, 0 for failure. If the return is 0, $!
  615.    should be set.
  616.    
  617. %oct
  618. oct(EXPR)
  619. oct EXPR
  620.    returns the decimal value given by interpreting EXPR
  621.    as an octal string. If EXPR starts "0x" it will be
  622.    taken as hex instead. To handle a general numeric
  623.     
  624.    $val = oct($val) if $val =~ /^0/;
  625.     
  626.    The inverse can be achieved with
  627.     
  628.    sprintf("%lo", $number)
  629.    
  630. %open
  631. open(FILEHANDLE,EXPR)
  632. open(FILEHANDLE)
  633. open FILEHANDLE
  634.    opens the file whose filename is given by EXPR and
  635.    places the filehandle in FILEHANDLE. If filename is
  636.    not given it is assumed to be held in the  scalar
  637.    variable of the same name as FILEHANDLE. Filenames
  638.    may be of the forms:-
  639.     
  640.    "<foo"  read   (default)
  641.    "foo"   (as above)
  642.    ">foo"  write
  643.    ">>foo" append
  644.    "+>foo" read/write
  645.    "+<foo" (as above)
  646.    "|foo"  pipe to foo
  647.    "foo|"  pipe from foo
  648.    "-"     open STDIN
  649.    ">-"    open STDOUT
  650.  
  651.    [N.B. executables compiled with CLib support redirection
  652.    and thus can be opened as pipes. Others can be co-erced
  653.    into this behaviour if their name is prefixed with a '%'.
  654.    E.g. open(LIB, "%LibFile Lib -l |")
  655.  
  656.    Forgetting this is also a common source of error with
  657.    `commands` which also require redirection to work
  658.    correctly.]
  659.     
  660.    open returns non-zero for success, the undefined
  661.    value otherwise.
  662.     
  663.    Opening an already open file does an implicit close
  664.    first, but does not  reset the line counter ($.) as
  665.    an explicit close would.
  666.     
  667.    Opening involving dup, ">&" etc, is not supported
  668.    under RISC OS, neither is  "-|" or "|-".
  669.    
  670. %opendir
  671. opendir(DIRHANDLE,EXPR)
  672.    opens the direcxotry specified by EXPR
  673.    returns true if succesful
  674.    directory and file handles have distinct name sapces.
  675.    
  676. %ord
  677. ord(EXPR)
  678. ord EXPR
  679.    returns the ASCII value of the first character of EXPR
  680.    
  681. %pack
  682. pack(TEMPLATE,LIST)
  683.    returns a string equivalent to a binary structure
  684.    encoding the items of LIST as dicated by the
  685.    TEMPLATE The TEMPLATE is a string containing one or
  686.    more field specifiers of the  form '<key><count>'.
  687.    The field specifiers may be separated by whitespace 
  688.    which is ignored. The <key>  may be any of
  689.     
  690.    a       An ASCII string, null padded
  691.    A       An ASCII string, space padded
  692.    b       A bit string, lo-to-hi, vec() compatible
  693.    B       A bit string, hi-to-lo
  694.    h       A hex string, low nybble first
  695.    H       A hex string, high nybble first
  696.    c       A signed char
  697.    C       An unsigned char
  698.    s       A signed short
  699.    S       An unsigned short
  700.    i       A signed integer
  701.    I       An unsigned integer
  702.    l       A signed long
  703.    L       An unsigned long
  704.    f       A single-precision float 
  705.    d       A double-precision float (default for perl)
  706.    p       A pointer to a string
  707.    x       A null byte
  708.    X       Back up a byte
  709.    @       Null fill to absolute position
  710.    u       A uuencoded string
  711.    T       A 5-byte 2s complement integer
  712.     
  713.    The <count> is a simple repeat count except for a, A
  714.    where it is a character  length. A count of '*'
  715.    means use the rest of the LIST. A missing count is
  716.    treated as 1.
  717.  
  718.         POSSIBLE BUG. There is a suspicion that the 'hHbB'
  719.         templates are broken.
  720.    
  721. %pop
  722. pop(ARRAY)
  723. pop ARRAY
  724.    removes and retruns the last item of the array. It
  725.    has the same effect as
  726.     
  727.    $ARRAY($#ARRAY--)
  728.     
  729.    returns undef if the array was empty
  730.    
  731. %print
  732. print(FILEHANDLE LIST)
  733. print(LIST)
  734. print FILEHANDLE LIST
  735. print LIST
  736. print
  737.    prints the LIST - whcih may be a string or
  738.    comma-separated list of strings, to the file
  739.    specified by FILEHANDLE. The FILEHANDLE may be
  740.    indirect via a simple scalar variable as normal. If
  741.    the FILEHANDLE is omitted, uses the currently
  742.    selected ouptut stream which will be STDOUT in the
  743.    absence of specific select statements. If LIST is
  744.    omitted uses $_. Remember that because print expect
  745.    a LIST its operands are evaluated in an array
  746.    context, thus
  747.    
  748.         print <T>;
  749.     
  750.    will not print a single line from T, but rather the
  751.    entire contents of T.
  752.    
  753. %printf
  754. printf(FILEHANDLE FORMAT, LIST)
  755. printf(FORMAT, LIST)
  756. printf FILEHANDLE FORMAT, LIST
  757. printf FORMAT, LIST
  758.    equivalent to
  759.    
  760.         print FILEHANDLE sprintf(LIST);
  761.    
  762. %push
  763. push(ARRAY, LIST)
  764.    Treats array (the '@' is optional) as a stack and
  765.    pushes LIST onto the end.
  766.     
  767.    Equivalent to
  768.     
  769.    foreach $value (LIST)
  770.    {
  771.    $ARRAY[++$#ARRAY] = $value;
  772.    }   
  773.    
  774. %rand
  775. rand(EXPR)
  776. rand EXPR
  777. rand
  778.    Returns an arbitrary real number between 0 and EXPR
  779.    (exclusive). EXPR  should be positive. EXPR is taken
  780.    as 1 if omitted.
  781.    
  782. %read
  783. read(FILEHANDLE,SCALAR,LENGTH,OFFSET)
  784. read(FILEHANDLE,SCALAR,LENGTH)
  785.    attempts to read LENGTH bytes from FILEHANDLE into
  786.    SCALAR. Returns number of bytes actually read, 0 on
  787.    eof, undef on failure. If OFFSET is used it
  788.    specifies where, in SCALAR, to start placing the
  789.    bytes  read. Do not intersperse with calls to
  790.    sysread() Read may be buffered by the system
  791.    
  792. %readdir
  793. readdir(DIRHANDLE)
  794. readdir DIRHANDLE
  795.    In array context returns all the (remaining) entries
  796.    in a directory opened using opendir. In a scalar
  797.    context returns the next entry only. If there are no
  798.    more gives an empty list (array) or undef (scalar).
  799.    
  800. %rename
  801. rename(OLDNAME, NEWNAME)
  802.    renames the file in question. Returns 1 for success.
  803.    Unlike Unix implementations, if NEWNAME already
  804.    exists it is not destroyed. Unfortunately, rename
  805.    still returns 1 in this instance (as it does if
  806.    OLDNAME doesn't exist!).
  807.    
  808. %require
  809. require(EXPR)
  810. require EXPR
  811. require
  812.    includes and executes any Perl code found in the
  813.    file whose name is given by EXPR. Require will check
  814.    the @INC array to ensure that the code has not
  815.    already been included and will update the @INC array
  816.    if necessary. require will also use the search path
  817.    held in @INC to find the file if  necessary.
  818.    
  819. %reset
  820. reset(EXPR)
  821. reset EXPR
  822. reset
  823.    reset EXPR treats EXPR as a list of characters and
  824.    resets all variables (including arrays) beginning
  825.    with one of those letters. Thus
  826.    
  827.         reset 'a-z';
  828.    
  829.    resets all variables whose names begin with a
  830.    lowercase letter. Note that reset 'A-Z' would kill
  831.    the ARGV, ENV, INC, and SIG arrays. Resetting an
  832.    array bound to a dbm file merely flushes the cache.
  833.    For single variables - particularly arrays -
  834.    undef(ARRAY) is more efficient.
  835.     
  836.    Reset with no parameter resets ?? searches so that
  837.    they match again.
  838.     
  839.    The scope of a either type of reset is confined to
  840.    the current package.
  841.     
  842.    Reset always returns 1.
  843.    
  844. %return
  845. return LIST
  846.    returns from a subroutine with the value specified.
  847.    Illegal outside subroutines.
  848.    Allowing an implicit return of the last expression
  849.    evaluated is more  efficient.
  850.    
  851. %reverse
  852. reverse(LIST)
  853. reverse LIST
  854.    In an array context returns an array containing the
  855.    elements of LIST in the opposite order. It is
  856.    implemented fairly efficiently.
  857.     
  858.    It can also invert associative arrays
  859.     
  860.    
  861.         %VNE = reverse %ENV
  862.     
  863.    In a scalar context returns a string consisting of
  864.    the first element of LIST in reverse order.
  865.    
  866. %rewinddir
  867. rewinddir(DIRHANDLE)
  868. rewinddir DIRHANDLE
  869.    causes the next use of readdir() on the DIRHANDLE to
  870.    return the first  (scalar context) or all (array
  871.    context) entries in the directory specified once
  872.    again.
  873.    
  874. %rindex
  875. rindex(STR,SUBSET,OFFSET)
  876. rindex(STR,SUBSET)
  877.    works a index does except that it returns the
  878.    position of the last occurence of of SUBSTR in STR. 
  879.    OFFSET, if specified, is the rightmost position that
  880.    may be returned.
  881.    
  882. %rmdir
  883. rmdir(FILENAME)
  884. rmdir FILENAME
  885.    Deletes the directory specified by FILENAME if it
  886.    exists and is empty when it returns 1. Otherwise it
  887.    returns 0 with an error code in $!.
  888.    
  889. %s
  890. s/PATTERN/REPLACEMENT/[g][i][e][o]
  891.    searches a string for the pattern, if found replaces
  892.    that pattern with the  replacement text, and returns
  893.    the number of replacements made. Only the first
  894.    occurence is replaced unless the g (global)
  895.    modifiers is used. The i modifier causes
  896.    case-insensitive behaviour. The e modifier means
  897.    that REPLACEMENT will be treated as an expression 
  898.    rather than as a string. Additional 'e's may be
  899.    specified to cause  additional evaluation of the
  900.    resulting string. The pattern is also subject to
  901.    variable interpolation as strings usually are. The o
  902.    modifier may be used to indicate once-only
  903.    evaluation of the string where the interpolated
  904.    variables will not change over the life time of the
  905.    substitution and may be a valuable optimization in
  906.    loops. The o  modifier has no effect if there are no
  907.    variables in the pattern.
  908.     
  909.    Any non-alpahanumeric may be used instead of the
  910.    '/'s. In particular single quotes prevent
  911.    interpretation of the replacement text (this is,
  912.    however,  over-ridden by the e modifier). If
  913.    backquotes are used, the replacement  string is a
  914.    command whose result will be used as the replacement
  915.    text.
  916.     
  917.    If no other string is specified using the =~ or !~
  918.    operators, then $_ is searched and modified. The
  919.    string specified must be an lvalue.  
  920.     
  921.    Forgetting that the second subpattern is specified
  922.    as \2 within the pattern but $2 within the
  923.    replacement is a common error. (As is thinking that
  924.    \0 is the first sub-pattern because of contact with
  925.    brain-dead editors such as !Edit or !SrcEdit). \0 is
  926.    a null, \1 is the first subpattern.
  927.    
  928. %scalar
  929. scalar(EXPR)
  930.    A pseudo function forcing EXPR to be evaluated in a
  931.    scalar context rather than in an array context.
  932.    Useful, therefore, when EXPR is to be used as an
  933.    element of a list.
  934.     
  935.    Not using scalar in operations such as
  936.     
  937.    local($nextline) = scalar(<STDIN>);
  938.     
  939.    is a common error. The argument of local is a list.
  940.    Assignment to a list is an array operation. Thus
  941.    <STDIN> would be in an array context resulting in a
  942.    read to eof rather than eol were it not for the use
  943.    of scalar.
  944.    
  945. %seek
  946. seek(FILEHANDLE,POSITION,WHENCE)
  947.    positions the file pointer for FILEHANDLE as
  948.    specified. WHENCE specifies  what POSITION should be
  949.    taken as relative to: 0 for beginning, 1 for current
  950.    position, 2 for end of file. POSITION is thus >=0 if
  951.    WHENCE is 0, <=0 if  WHENCE is 2, and positive or
  952.    negative for a WHENCE of 1.
  953.     
  954.    seek returns 1 for success and 0 for failure.
  955.     
  956.    seek is useful for resetting eof on dynamic files,
  957.    e.g.
  958.     
  959.    for (;;) {
  960.    while (<FILE>) {
  961.    print;
  962.    }
  963.    sleep 5;
  964.    seek(FILE,0,1)  # Seek to the current poistion in
  965.    the file # thus clearing the eof error }
  966.     
  967.    which would print out lines as they were added *IF*
  968.    RISC OS allowed writing to files open for reading
  969.    elsewhere. Boring, or what.
  970.    
  971. %seekdir
  972. seekdir(DIRHANDLE,POS)
  973.    Sets the current position for the readdir() routine.
  974.    On some systems POS must be a value returned by
  975.    telldir(), but under RISC OS integers 0 .. n appear
  976.    to be fine.
  977.    
  978. %select
  979. select(FILEHANDLE)
  980. select
  981.    
  982. select(RBITS,WBITS,EBITS,TIMEOUT)
  983.  
  984.    The first form returns the currently selected
  985.    filehandle and sets it if FILEHANDLE is supplied.
  986.    The currently selected filehandle is significant to
  987.    'write' or 'print' when used without a filehandle.
  988.    Special variables related to output also refer to
  989.    the current filehandle.
  990.     
  991.    Subroutines should ideally exit with the selected
  992.    filehandle unaltered. Since FILEHANDLE may be an
  993.    expression evaluating to a filehandle it is not
  994.    difficult to do a save and restore.
  995.     
  996.    Which leads to one of Larrys' favourite bits of
  997.    bizarre Perl: setting stderr unbuffered while
  998.    leaving the current filehandle unaltered.
  999.     
  1000.    select((select(STDERR), $| = 1)[$[])
  1001.     
  1002.    The second form of select (which has nothing to do
  1003.    with the first) is not implemented under RISC OS
  1004.    
  1005. %shift
  1006. shift(ARRAY)
  1007. shift ARRAY
  1008. shift
  1009.    returns the first element of an array and shortens
  1010.    the array by one element from the left. Without
  1011.    arguments operates on @ARGV in the main program and
  1012.    @_ in  subroutines. If the array has no elements it
  1013.    returns the undefined value.
  1014.    
  1015. %sin
  1016. sin(EXPR)
  1017. sin EXPR
  1018.    returns the sine of EXPR (taken as radians).
  1019.    
  1020. %sleep
  1021. sleep(EXPR)
  1022. sleep EXPR
  1023. sleep
  1024.    suspends the script for EXPR seconds.
  1025.    If EXPR is omitted sleeps forever!
  1026.    On some systems sleep may be interrupted by a signal
  1027.    and suitable handler, but under RISC OS a SIGINT
  1028.    appears to bypass the handler if the script is
  1029.    sleeping, so the script just terminates.
  1030.     
  1031.    syscall() and suitable swis would need to be used
  1032.    instead.
  1033.     
  1034.    returns the number of seconds actually slept. This
  1035.    may be a lot longer than the number asked for if
  1036.    RISC OS has its attention distracted in the meantime
  1037.    (e.g. by a non-wimp task).
  1038.    
  1039. %sort
  1040. sort(SUBROUTINE LIST)
  1041. sort(LIST)
  1042. sort SUBROUTINE LIST 
  1043. sort LIST 
  1044.    sorts the list and returns a sorted array. If
  1045.    SUBROUTINE is omitted soes a string comparison sort.
  1046.    SUBROUTINE, if specified, is the name of a
  1047.    subroutine that will return -1, 0, or 1, when
  1048.    presented with two elements.
  1049.    
  1050.    For efficiency reasons, SUBROUTINE is not called in
  1051.    the normal way. It may not be recursive, @_ is not
  1052.    used, the two parameters are passed by reference as
  1053.    $a and $b.
  1054.     
  1055.    If SUBROUTINE is a simple scalar variable this
  1056.    should evaluate to the name of the actual subroutine
  1057.    to use.
  1058.     
  1059.    sub numerically { $a <=> $b; }
  1060.    @sortednumerically = sort numerically 53,29,11,32,7;
  1061.     
  1062.    note that
  1063.     
  1064.         sort reverse @a
  1065.     
  1066.    is equivalent to
  1067.    
  1068.         reverse sort @a
  1069.     
  1070.    because of the way that lists work.
  1071.    
  1072. %splice
  1073. splice(ARRAY,OFFSET,LENGTH,LIST)
  1074. splice(ARRAY,OFFSET,LENGTH)
  1075. splice(ARRAY,OFFSET)
  1076.    removes the elements of ARRAY designated by OFFSET
  1077.    and LENGTH and replaces  them with LIST if LIST is
  1078.    provided. OFFSET may be negative in which case it is
  1079.    reckoned from rigyt to left. Returns the elements
  1080.    removed. The array shrinks or grows as needed. If
  1081.    LENGTH is omitted everything from OFFSET onwards is
  1082.    removed. Note the following equivalencies:
  1083.     
  1084.    push(@a, $x, $y)        splice(@a, $#a+1, 0, $x, $y)
  1085.    pop(@a)                 splice(@a, -1)
  1086.    shift(@a)               splice(@a, 0, 1)
  1087.    unshift(@a, $x, $y)     splice(@a, 0, 0, $x, $y)
  1088.    $a[$x]=$y               splice(@a, $x, 1, $y)
  1089.    
  1090. %split
  1091. split(/PATTERN/,EXPR,LIMIT)
  1092. split(/PATTERN/,EXPR)
  1093. split(/PATTERN/)
  1094. split
  1095.    splits the string specified by EXPR into an array of
  1096.    strings which it returns. If EXPR is omitted, split
  1097.    uses $_. The pattern matches the delimiters
  1098.    separating the sub-strings. The  delimiters are not
  1099.    returned. 
  1100.     
  1101.    In a scalar context splits into @_ and returns the
  1102.    number of substrings. In an array context the split
  1103.    can be forced into @_ by using ?? as the  pattern
  1104.    delimiters (but the array value is still returned).
  1105.    If PATTERN is elided the split is on whitespace: /[
  1106.    \t\n]+/ PATTERN may match more than one character.
  1107.    If the match fails the original string is returned. 
  1108.     
  1109.    If a LIMIT is specified the split is into no more
  1110.    than LIMIT fileds. If LIMIT is unspecified any
  1111.    trailing null fileds are stripped.
  1112.    
  1113.    If PATTERN can match the null string then the split
  1114.    is into individual characters at that point.
  1115.     
  1116.    join(':', split(/ */,'hi there'));
  1117.     
  1118.    returns "h:i:t:h:e:r:e". Notice that the space -
  1119.    which matched as a  delimiter - is not returned as
  1120.    is the norm for delimiters.
  1121.     
  1122.    LIMIT is widely used for partial splitting, as in
  1123.     
  1124.    ($command,$flags,$filelist)=split(/[ \t]+/,$_,3);
  1125.    
  1126.    In the case of assignment to a list if a LIMIT is
  1127.    not given a limit of one greater than the number of
  1128.    elements in the list is actually used. Splitting
  1129.    into more fields than are needed should be avoided
  1130.    for efficiency.
  1131.     
  1132.    If the delimiters are required, then parentheses
  1133.    should be used in the  pattern round those
  1134.    delimiters wanted
  1135.     
  1136.    split(/(-)|,/, '1-10,20');
  1137.     
  1138.    produces
  1139.     
  1140.    (1,'-',10,20)
  1141.     
  1142.    The /PATTERN/ argument may be replaced with a
  1143.    variable as /$pattern/, in this case the o modifier
  1144.    may be used for invariant patterns /$pattern/o
  1145.     
  1146.    A literal space replacing the whole of PATTERN
  1147.    splits on whitespace but  ignores leading
  1148.    whitespace. These are all subtley different:-
  1149.     
  1150.    split or split(/[ \t]+/) splits on whitespace, leading space gives null fields
  1151.     
  1152.    split(' ')       splits on whitespace, no leading null fields
  1153.     
  1154.    split(/ /)       split on literal single space, may give nulls
  1155.    
  1156. %sprintf
  1157. sprintf(FORMAT,LIST)
  1158.    returns a string which is created from LIST using
  1159.    the supplied FORMAT. The FORMAT is a string
  1160.    containing fileds of the approximate form  %m.nx,
  1161.    one per element of the list to be used.
  1162.     
  1163.    The m is the minimum field length, -ve for left
  1164.    justified, padding is done with zeroes for numbers
  1165.    and spaces for non-numerics.
  1166.     
  1167.    The n is typically a maximum length or a precision
  1168.    for exponential formats.
  1169.     
  1170.    The x is one of:-
  1171.     
  1172.    s       string
  1173.    c       character       
  1174.    d       decimal number
  1175.    ld      long decimal number
  1176.    u       unsigned decimal number
  1177.    lu      long unsigned decimal number
  1178.    x       hexadecimal number
  1179.    lx      long hexadecimal number
  1180.    o       octal number
  1181.    lo      long octak number
  1182.    e       exponential fp
  1183.    f       fixed point fp
  1184.    g       compact fp
  1185.    
  1186. %sqrt
  1187. sqrt(EXPR)
  1188. sqrt EXPR
  1189.    returns the square root of EXPR. Returns the largets
  1190.    possible -ve number if asked for the square root of
  1191.    a negative quantity.
  1192.    
  1193. %srand
  1194. srand(EXPR)
  1195. srand EXPR
  1196.    sets the random number seed with the value of EXPR.
  1197.    If EXPR is omitted does srand(time) which may be
  1198.    fairly predictable.
  1199.    
  1200. %stat
  1201. stat(FILEHANDLE)
  1202. stat FILEHANDLE
  1203. stat(EXPR)
  1204.    returns an eight element array
  1205.     
  1206.    ($found,$filetype,$loadaddress,$execaddress,$length,$attributes,$ts1,$ts2)
  1207.    =stat($file);
  1208.     
  1209.    $found is 0 for not found, 1 for a file, and 2 for a
  1210.    directory
  1211.     
  1212.    $ts1 is a RISC OS 5-byte time (see the P key to
  1213.    unpack), i.e. centiseconds from 00:00:00.00 1/1/1900
  1214.     
  1215.    $ts2 is Unix format, i.e.seconds from 00:00:00 1/1/1970
  1216.    
  1217. %study
  1218. study(SCALAR)
  1219. study SCALAR
  1220. study
  1221.    builds an index for SCALAR ($_ if unspecified). This
  1222.    can result in speed enhancement if many pattern
  1223.    matches are to be done against the string. It
  1224.    carries the overhead of building the index so may or
  1225.    may not be faster overall. Short constant string
  1226.    searches benefit most, but not if they are anchored.
  1227.    Only one study may be active at a time. A new study
  1228.    forgets the older one.
  1229.     
  1230.    For strings not known till runtime, search loops can
  1231.    be built as strings and then 'eval'ed. Together with
  1232.    setting $/ to input entire files as single records
  1233.    (given  the memory ;-) this can be extremely fast.
  1234.    
  1235. %substr
  1236. substr(EXPR,OFFSET,LENGTH)
  1237. substr(EXPR,OFFSET)
  1238.    extracts a substring from EXPR and returns it.
  1239.    OFFSET runs from $[, normally 0
  1240.    If OFFSET is negative it is a character length from
  1241.    the right of the string If LENGTH is omitted
  1242.    everything to the end of the string is returned.
  1243.    
  1244.    substr() can be an lvalue if EXPR is also an lvalue.
  1245.    In this case the string may grow or shrink if if
  1246.    LENGTH is not the same as the length of the item
  1247.    assigned. 
  1248.    
  1249. %syscall
  1250. syscall(LIST)
  1251. syscall LIST
  1252.    Normally called with LIST containing
  1253.     
  1254.    ($swi_name_or_number, $r0, ..., %$r9)
  1255.     
  1256.    the swi specified is called with the remaining
  1257.    values placed in the registers. Only as many
  1258.    registers as are needed need be specified.
  1259.    
  1260.    If $rn is a number it is used directly, if it is a
  1261.    string a pointer to the string is passed.
  1262.     
  1263.    Care should be taken because of Perl's tendency to
  1264.    convert numbers to strings and  vice versa. Use
  1265.    $rn+0 to ensure a numeric interpretation and $rn.''
  1266.    to ensure a  string interpretation in cases of
  1267.    doubt.
  1268.     
  1269.    Obviously if values are returned in strings the
  1270.    caller must ensure that the string is large enough
  1271.    to accept the return value.
  1272.     
  1273.    Buffers may be created as
  1274.     
  1275.    $buffer='\0' x 512;      # A 512 byte null filled buffer
  1276.     
  1277.    or
  1278.    
  1279.    $buffer=pack("x512",'') # Another one.
  1280.     
  1281.    Generally with strings used for return values,
  1282.    call-by-reference is wanted.  NOT call by value, so
  1283.    be careful with assignments, particularly in
  1284.    subroutines.
  1285.    
  1286.    Actual pointers can be obtained by using
  1287.     
  1288.    $pointer=unpack("I",pack("p",$buffer))
  1289.     
  1290.    though the use to which such 'pointers' are put is
  1291.    at the users's risk! Pointer  comparison is known to
  1292.    be ok, and some pointer arithemetic, eg
  1293.     
  1294.    $end_of_buffer=unpack("I",pack("p",$buffer))+length($buffer);
  1295.     
  1296.    for those awkward little swis that want start and
  1297.    end rather than start and length.
  1298.     
  1299.    Syscall returns either a null string (in the case of
  1300.    errors) in which instance $! may be diagnostic or a
  1301.    packed structure containing ARM registers R0 to R9.
  1302.     
  1303.    (@reg[0..8],$flags)=unpack('I10', syscall("Wimp_Initialise", @reg)); 
  1304.    
  1305. %system
  1306. system(LIST)
  1307. system LIST 
  1308.    attempts to have the sytem execute LIST. Returns
  1309.    unlike exec. The value returned should be zero for
  1310.    success and -ve for failure but this isnot
  1311.    completely consistent under RISC OS. $! will hold
  1312.    the error, if any.
  1313.    
  1314. %tell
  1315. tell(FILEHANDLE)
  1316. tell FILEHANDLE 
  1317. tell
  1318.    Returns the position of the file pointer (in bytes).
  1319.    FILEHANDLE may be an  expression evaluating to a
  1320.    file handle. If FILEHANDLE is omitted, tell targets
  1321.    the last file read. tell() has no meaning for
  1322.    devices or pipes.
  1323.    
  1324. %telldir
  1325. telldir(DIRHANDLE)
  1326. telldir DIRHANDLE
  1327.    Returns the current position of readdir() on
  1328.    DIRHANDLE. May be used as a  parameter to seekdir()
  1329.    
  1330. %time
  1331. time
  1332.    This function returns the number of seconds since
  1333.    1/1/1970.
  1334.    
  1335. %tr
  1336. tr/SEARCHLIST/REPLACEMENTLIST/[c][d][s]
  1337. y/SEARCHLIST/REPLACEMENTLIST/[c][d][s]
  1338.    
  1339.    SEARCHLIST and REPLACEMENTLIST are placed in a
  1340.    one-to-one correspondence. If  REPLACEMENTLIST is
  1341.    shorter than SEARCHLIST then the last character of 
  1342.    REPLACEMENTLIST is repeated as necessary (except
  1343.    with the d option). If  REPLACEMENTLIST is null a
  1344.    copy of SEARCHLIST is used (except with the d
  1345.    option).
  1346.    
  1347.    The function replaces all characters in SEARCHLIST
  1348.    with their corresponding  character from
  1349.    REPLACEMENTLIST. The returned value is the number of 
  1350.    replacements made.
  1351.     
  1352.    The c option complements SEARCHLIST: in effect the
  1353.    SEARCHLIST given is removed from the range \001-\377
  1354.    and the result used as SEARCHLIST.
  1355.     
  1356.    The d option deletes all characters within
  1357.    SEARCHLIST that are not found in REPLACEMENTLIST.
  1358.     
  1359.    The s option causes any substitutions that would
  1360.    result in multiple identical  REPLACEMENTLIST
  1361.    characters being output to be replaced by a single
  1362.    occurence of that character.
  1363.     
  1364.    y is a synonym for tr.
  1365.     
  1366.    If no string is specified via =~ or !~ the $_ string
  1367.    is used. The string  specified must be an lvalue.
  1368.    
  1369. %truncate
  1370. truncate(FILEHANDLE,LENGTH)
  1371. truncate(EXPR,LENGTH)
  1372.    This function does not appear to be implemented in
  1373.    the current port.
  1374.    
  1375. %undef
  1376. undef(EXPR)
  1377. undef EXPR
  1378. undef
  1379.    Makes the value of EXPR (which must be an lvalue)
  1380.    undefined. Subroutine names should be prefixed with
  1381.    '&'. Storage is recovered, so undeffing large arrays
  1382.    when they are finished with can make smaller tasks.
  1383.    The function always returns the undef value. The
  1384.    principal use of undef with no argument is as an
  1385.    error return from subroutines.
  1386.    
  1387. %unlink
  1388. unlink(LIST)
  1389. unlink LIST
  1390.    Equivalent to *remove - i.e. tries to delete the
  1391.    files named, but does not provoke an error if it
  1392.    cannot. unlink() will not delete directories (unless
  1393.    Perl is started with the -U flag). Use rmdir()
  1394.    instead.
  1395.    
  1396. %unpack
  1397. unpack(TEMPLATE,EXPR)
  1398.    Almost the reverse of pack(), except that some
  1399.    templates make no sense when packing, others make no
  1400.    sense when unpacking.
  1401.     
  1402.    EXPR is a string representing a structure and unpack
  1403.    unpacks this into an array according to the pattern
  1404.    given in TEMPLATE.
  1405.    
  1406.    Keys recognized in TEMPLATE are
  1407.    
  1408.  
  1409.    a       An ASCII string, unstripped
  1410.    A       An ASCII string, trailing spaces and nulls stripped
  1411.    b       A bit string, lo-to-hi, vec() compatible
  1412.    B       A bit string, hi-to-lo
  1413.    h       A hex string, low nybble first
  1414.    H       A hex string, high nybble first
  1415.    c       A signed char
  1416.    C       An unsigned char
  1417.    s       A signed short
  1418.    S       An unsigned short
  1419.    i       A signed integer
  1420.    I       An unsigned integer
  1421.    l       A signed long
  1422.    L       An unsigned long
  1423.    f       A single-precision float 
  1424.    d       A double-precision float (default for perl arithmetic)
  1425.    p       A pointer to a string
  1426.    x       Skip forward a byte
  1427.    X       Back up a byte
  1428.    @       Go to absolute position in string for next field, @* is end of string
  1429.    u       A string to uudecode
  1430.    T       A 5-byte 2s complement integer
  1431.    P       A pointer to a string whose length is given in the count.
  1432.    
  1433.    P is not recognized in pack() as there is
  1434.    no way to ensure the exact length of the string.
  1435.    Reads exactly count bytes from the string pointed
  1436.    to, regardless of what these bytes are (p1 would
  1437.    stop at a \0).
  1438.     
  1439.    The <count> is a simple repeat count except for a, A
  1440.    where it is a character  length. A count of '*'
  1441.    means use the rest of the LIST. A missing count is
  1442.    treated as 1.
  1443.     
  1444.    Prefixing a TEMPLATE field with %<num> means that
  1445.    you want a <num>-bit checksum
  1446.    of the item rather than the item itself.
  1447.  
  1448.         POSSIBLE BUG: There is a suspicion that the 'hHbB'
  1449.         templates are broken
  1450.    
  1451. %unshift
  1452. unshift(ARRAY,LIST)
  1453.    Does the opposite of a shift().
  1454.    It attaches LIST to the front of array ARRAY and
  1455.    adjusts the length of ARRAY as needed.
  1456.    
  1457. %values
  1458. values(ASSOC_ARRAY)
  1459. values ASSOC_ARRAY
  1460.    returns a normal array consisting of all the
  1461.    valuesin the named associative array. Using values
  1462.    on an array bound to a dbm file can produce huge
  1463.    arrays.
  1464.    
  1465. %vec
  1466. vec(EXPR,OFFSET,BITS)
  1467.    treats the string which EXPR evaluates to as an
  1468.    array of bits (the conversion is as unsigned
  1469.    integers). The OFFSET is the number of *elements* to
  1470.    skip over (not the number of bits), BITS is the
  1471.    number of bits in each element.
  1472.     
  1473.    BITS must be one of 1,2,4,8,16,or 32.
  1474.     
  1475.    The ordering is such that vec($string,0,1) is the
  1476.    lowest bit of the first byte of $string.
  1477.  
  1478.         (IE. the ordering is 32107654ba98fedc
  1479.         where 0-f represent 0-15)
  1480.     
  1481.    A true bit vector (i.e. with BITS=1) can be
  1482.    translated to/from strings of 1s and 0s by using a
  1483.    b* template with pack() and unpack().
  1484.  
  1485.    vec() may be used as an lvalue to set specific bits
  1486.  
  1487.     Note that EXPR is a scalar and will be
  1488.     irredeemably treated as the printed representation
  1489.     of EXPR. Thus vec(0xff,... will return a bit
  1490.     string related to 0x323535 - i.e. the character
  1491.     string '255'. 
  1492.  
  1493.     
  1494.    This limits its usefulness somewhat.
  1495.    
  1496. %wantarray
  1497. wantarray
  1498.    This pseudo function returns true if the current
  1499.    context is looking for an array and false if it is
  1500.    looking for a scalar. Typical use
  1501.    
  1502.         return wantarray ? () : undef;
  1503.    
  1504. %warn
  1505. warn(LIST)
  1506. warn LIST
  1507.    Similar to die() but doesn't exit. 
  1508.    E.g.
  1509.     
  1510.    warn "Debugging enabled" if $debug
  1511.    
  1512. %write
  1513. write(FILEHANDLE)
  1514. write(EXPR)
  1515. write
  1516.    writes a formatted record to the specified file
  1517.    using the format established  for that file. By
  1518.    default that is the format with the same name as the
  1519.    FILEHANDLE, but the format for the current
  1520.    filehandle may be explicitly set with $~.
  1521.     
  1522.    The default top-of-page format has the same name as
  1523.    the format with _TOP appended, but may be set using
  1524.    $^
  1525.     
  1526.    The number of lines left on a page is held in $-
  1527.    which can be set to 0 to force a new page for the
  1528.    next write() which will be done automatically if
  1529.    there is insufficient room for the next record.
  1530. %$_
  1531. $_      Default input, parameter, and pattern
  1532. %$.
  1533. $.      Current input line on last filehandle read
  1534. %$/
  1535. $/      Input record separator, newline by default
  1536. %$,
  1537. $,      Output field separator for print operator
  1538. %$"
  1539. $"      Separator for array elements interpolated 
  1540.         in strings
  1541. %$\
  1542. $\      Output record separator for print operator
  1543. %$#
  1544. $#      Output format for numbers, default "%.20g"
  1545. %$*
  1546. $*      If set to 0 (default) assume in pattern
  1547.         matching that strings contain only a single
  1548.         line. If set to 1, strings will be matched as
  1549.         if they might contain multiple lines.
  1550. %$?
  1551. $?      Status return from last `command`, pipe, or
  1552.         system operator.
  1553. %$]
  1554. $]      Perl version string
  1555. %$[     
  1556. $[      Index of first elements in arrays. Default 0.
  1557. %$;
  1558. $;      Subscript separator for multi-dimensional 
  1559.         array emulation. Default \034
  1560. %$!
  1561. $!      As a number evaluates to an error no. As a string
  1562.         evaluates as the last error string.
  1563.         I.e. set to the value of _kernel_last_oserror
  1564.         whenever an OS call returns an error.
  1565. %$@
  1566. $@      Perl error message from last eval, require, etc
  1567. %$:
  1568. $:      The set of characters on which strings may be
  1569.         broken in '^' fields of formats.
  1570.         Default ' \n-'
  1571. %$0
  1572. $0      The name of the file containing the script
  1573.         being executed.
  1574. %$$
  1575. $$      Not implemented under RISC OS     
  1576. %$<
  1577. $<      The pathname of the CSD when Perl started
  1578.         Note, under Unix this would the real uid
  1579. %$>
  1580. $>      The pathname of the current CSD
  1581.         Note, under Unix this would be the effective uid
  1582. %$(
  1583. $(      Not implemented under RISC OS
  1584. %$)
  1585. $)      Not implemented under RISC OS
  1586. %$^T
  1587. $^T     The time (in time() format) when the script
  1588.         began execution
  1589. %$%
  1590. $%      Curent page number on currently selected output
  1591. %$=
  1592. $=      Page length of currently selected ouput.
  1593.         Default 60
  1594. %$-
  1595. $-      Number of lines left on current page
  1596. %$~
  1597. $~      The name of the report format for the currently
  1598.         selected output channel
  1599. %$^
  1600. $^      The  name of the top of page format on the
  1601.         current output channel
  1602. %$|
  1603. $|      If set non-zero forces flushing of buffers
  1604.         after every write or print on the selected
  1605.         output channel. Default is 0.
  1606. %$ARGV
  1607. $ARGV   Current file name when reading from <>
  1608. %$&
  1609. $&      String matched by last pattern match
  1610. %$`
  1611. $`      String preceding match in last pattern
  1612. %$'
  1613. $'      String following match in last pattern
  1614. %$+
  1615. $+      The portion of the string matched by the last
  1616.         bracket in the last pattern
  1617. %@ARGV
  1618. @ARGV   array containing command line arguments
  1619. %@INC
  1620. @INC    array containg places to search for scripts
  1621. %@_
  1622. @_      Parameter array in subroutines. Used by split()
  1623.         in scalar contexts.
  1624. %ENV
  1625. ENV     Contains the current environment. May be written
  1626.         to set variables, but is read at script
  1627.         initialisation only - i.e. variables 
  1628.         set/altered by other tasks after the script 
  1629.         started will not be reflected in %ENV.
  1630. %INC
  1631. INC     List of files that have been 'require'-d.
  1632. %SIG
  1633. SIG     Array containing signal handlers. A signal
  1634.         handler may be installed by putting the name
  1635.         of a subroutine in the appropriate element.
  1636.         Help for kill() has a list of signals.
  1637.         The tokens 'IGNORE' and 'DEFAULT' are also
  1638.         valid in this array.
  1639. %FILE
  1640. __FILE__
  1641.    Token containing current filename. Returns (eval)
  1642.    inside evals. May not be interpolated in strings.
  1643. %LINE
  1644. __LINE__
  1645.    Line number in current script. May not be 
  1646.    interpolated in strings. Returns null string in
  1647.    evals.
  1648. %END
  1649. __END__
  1650.    Everything after this token is ignored by the parser
  1651.    but may be accessed via filehandle <DATA>.
  1652. %<<
  1653. <<STRING
  1654.    'here-is' text quoting.
  1655.    All following lines up to a line starting and 
  1656.    containing STRING alone are effectively inserted
  1657.    at the identified place. If quotes are used in the 
  1658.    first instance the following lines are treated
  1659.    accordingly.
  1660.         >>EOF
  1661.         >>"EOF" 
  1662.                 The lines are used after string interpolation
  1663.  
  1664.         >>'EOF'
  1665.                 The lines are used literally
  1666.         >>`EOF`
  1667.                 The lines are executed as commands
  1668. %re
  1669. Regular Expressions
  1670.         
  1671. 1.      Regular expressions may be separated
  1672.         by '|' to express alternatives.
  1673.         The '|' has a lower precedence than
  1674.         anything else.
  1675.  
  1676. 2.      Regular expressions surrounded by ()
  1677.         match whatever the enclosed expression 
  1678.         matches.
  1679.  
  1680. 3.      Assertions are:-
  1681.  
  1682.         ^ start of string (line if $* set)
  1683.         $ end of string (line if $* set)
  1684.         \b word boundary (except inside '[]' where it
  1685.                 is a backspace character)
  1686.         \B not a word boundary
  1687.         
  1688.         assertions match on the 'gaps' between characters
  1689.  
  1690. 4.      Quantified atoms are atoms followed by a quantifier.
  1691.         Quantifiers are:-
  1692.  
  1693.         {n,m} must occur at least n and not more than m times
  1694.         {n,}  must occur at least n times
  1695.         {n}   must occur exactly n times
  1696.         *     0 or more times - {0,}
  1697.         +     1 or more times - {1,}
  1698.         ?     0 or 1 times only - {0,1}
  1699.  
  1700. 5.      Atoms are:-
  1701.  
  1702.         \0 matches null
  1703.  
  1704.         \nn or \nnn matches the ASCII character whose
  1705.         octal code is nn or nnn.
  1706.         
  1707.         \xnn matches the ASCII character whose code
  1708.         in hexadecimal is nn.
  1709.  
  1710.         \cx where x is a single character matches
  1711.         the corresponding control character,
  1712.         thus \cI and \x09 are equivalent atoms. 
  1713.         
  1714.         \\ matches \
  1715.  
  1716.         \b matches backspace, but only if inside a
  1717.         character class '[]'.
  1718.  
  1719.  
  1720.         A list of characters in square brackets, [],
  1721.         matches any character in the brackets. If the
  1722.         first character is '^' the match is for any
  1723.         character not in the brackets. If ']' is needed
  1724.         as a character it must be the first character 
  1725.         (or second after '^'). If '^' is needed as a
  1726.         character it must not be first.
  1727.         Ranges may be used by inserting '-' between
  1728.         two characters. '\-' may be used to prevent
  1729.         this interpretation of hyphen.
  1730.         
  1731.         .       matches any character except \n
  1732.         \n      newline
  1733.         \r      carriage return
  1734.         \t      tab
  1735.         \f      formfeed
  1736.         \d      a digit         [0-9]
  1737.         \D      a non-digit     [^0-9]
  1738.         \w      an alphanumeric [0-9A-Z_a-z]
  1739.         \W      a non-alphanumeric
  1740.         \s      a whitespace    [ \t\n\r\f]
  1741.         \S      a non-whitespace
  1742.  
  1743.         Any character not previously mentioned 
  1744.         matches itself.
  1745.  
  1746.         Any character preceded by a backslash and not
  1747.         mentioned above matches itself.
  1748.  
  1749.         \1, \2, \3, .. are backreferences and match
  1750.         whatever the 1st, 2nd, 3rd, parenthesised
  1751.         expression matched.
  1752. %op
  1753.         Operators, from lowest to highest precedence
  1754.  
  1755. 1.      list operators,  nonassociative.
  1756.  
  1757. 2.      ,       left assoc., expression separator as C 
  1758.         e.g. <EXPR1>,<EXPR2> has the value <EXPR2>           
  1759.  
  1760. 3.      =       right assoc., assignment
  1761.         There are a host of assignment operators,
  1762.         += -= *= /= %= |= &= ^= >>= <<= **= .= x=
  1763.  
  1764. 4.      ?:      right assoc., conditional operator as C
  1765.  
  1766.         <CONDITION> ? <EXPR_T> : <EXPR_F>
  1767.  
  1768.         has value <EXPR_T> if <CONDITION> is true
  1769.         (non-zero, non-null, & defined) and <EXPR_F>
  1770.         otherwise.
  1771.  
  1772. 5.      ..              nonassoc., range operator.
  1773.  
  1774.         In array context returns an array of values from
  1775.         its left value to its right value.
  1776.  
  1777.         @digits = (0..9)
  1778.         @alphabet = ('A'..'Z')
  1779.  
  1780.         In scalar context returns a boolean value. This is 
  1781.         false as long as the left value is false, then true
  1782.         until the right value becomes true after which it
  1783.         returns false again. While returning false the
  1784.         right value is not evaluated and contrariwise
  1785.         while returning true.
  1786.  
  1787.         The 'true' value returned is actually a sequence
  1788.         number from '1' up to 'nnE0' (the E0 does not 
  1789.         affect the numeric value, but makes the last item
  1790.         easier to check for).
  1791.  
  1792.         If either (or both values) are static numbers an 
  1793.         implicit comparison with $. (the current input line
  1794.         number) is done.
  1795.  
  1796. 6.      ||      left assoc., logical or
  1797.  
  1798. 7.      &&      left assoc., logical and
  1799.  
  1800. 8.      |       left assoc., bitwise or
  1801.         ^       left assoc., bitwise eor
  1802.  
  1803. 9.      &       left assoc., bitwise and
  1804.  
  1805. 10.     ==      nonassoc., numeric equality
  1806.         !=      nonassoc., numeric inequality
  1807.         <=>     nonassoc., numeric comparison,
  1808.                 returns -1, 0, 1
  1809.         eq      nonassoc., string equality
  1810.         ne      nonassoc., string inequality
  1811.         cmp     nonassoc., string comparison
  1812.  
  1813. 11.     <       nonassoc., numeric less than
  1814.         >       nonassoc., numeric greater than
  1815.         <=      nonassoc.,
  1816.         >=      nonassoc.,
  1817.         lt      nonassoc., string less than
  1818.         gt      nonassoc., string greater than
  1819.         le      nonassoc.,
  1820.         ge      nonassoc.,
  1821.  
  1822. 12.     named unary operators   nonassoc.,
  1823.  
  1824. 13.     file test operators     nonassoc.,
  1825.         
  1826.         -Z EXPR
  1827.  
  1828.         EXPR is a filename or filehandle. $_ is used
  1829.         if EXPR is omitted (except -t which uses STDIN).
  1830.         If _ is used as the EXPR then the information
  1831.         from the last test is used (which saves another 
  1832.         statand is much more efficient).
  1833.  
  1834.     -r/-R       file is readable/publicly readable
  1835.     -w/-W       file is writeable/publicly writeable
  1836.     -e/-z/-s    file exists/has zero/has non-zero size
  1837.     -f/-d       file is a plain file/directory
  1838.     -t          filehandle is a terminal
  1839.     -T/-B       filename (not handle) is text/binary
  1840.                 this is based on an opinion formed
  1841.                 by examining the first few blocks.
  1842.                 both return true on null files. Both
  1843.                 return false on directories.
  1844.     -A          file time stamp test. Returns difference
  1845.                 in age between file and time program
  1846.                 started as given by $^T and measured
  1847.                 in days. Presumably can be negative
  1848.                 for files created after the program 
  1849.                 started.
  1850.                 Note that for directories this will use the
  1851.                 actual 'creation on disc' date as returned
  1852.                 by INFO and not the date displayed by Filer.
  1853.     -L          file is locked
  1854.  
  1855. 14.     <<      left assoc., bitwise shift left
  1856.         >>      left assoc., bitwise shift right
  1857.         
  1858. 15.     +       left assoc., addition
  1859.         -       left assoc., subtraction
  1860.         .       left assoc., string concatenation
  1861.  
  1862. 16.     *       left assoc., multiplication
  1863.         /       left assoc., f.pt. division
  1864.         %       left assoc., modulo division
  1865.         x       left assoc., string reproduction
  1866.  
  1867. 17.     =~      left assoc., pattern binding operator
  1868.         !~      left assoc., negated pattern binding
  1869.  
  1870. 18.     !       right assoc., negation operator
  1871.         -       right assoc., unary minus
  1872.         ~       right assoc., bitwise NOT
  1873.  
  1874. 19.     **      right assoc., exponentiation operator
  1875.  
  1876. 20.     ++      nonassoc., string or numeric autoincrement
  1877.         --      nonassoc., numeric autodecrement
  1878.  
  1879. 21.     '('     left assoc., functions and parenthesis
  1880. %glob
  1881. File globbing is supported if Glob is found on the Run$Path.
  1882. The RISC OS standard is followed
  1883.  
  1884.         *       any number of characters
  1885.         #       any single character
  1886. %mode
  1887. $Mode
  1888.         The current screen mode. Can be assigned to.
  1889. %Rows
  1890. $Rows
  1891.         Screen rows currently available
  1892. %Cols
  1893. $Cols   
  1894.         Screen columns currently available
  1895. %osrdch
  1896. &osrdch()
  1897.         returns a single character string from OS_ReadC
  1898. %oswrch
  1899. &oswrch(INT)
  1900.         writes the character whos ASCII code is INT
  1901.         using OS_WriteC. Returns 1 for success, undef for
  1902.         failure.
  1903. %osrdstr
  1904. &osrdstr(LEN,LO,HI)
  1905.         reads a string using OS_ReadLine. Uses a buffer of 
  1906.         length LEN characters to hold it internally. LO and
  1907.         HI are boundaries on the codes accepted, default
  1908.         32 and 255. Returns the string.
  1909. %oswrstr
  1910. &oswrstr(STR)
  1911.         writes STR to the screen. STR may contain control
  1912.         characters which will be interpreted as VDU codes,
  1913.         e.g. &oswrstr("\026\000") changes to mode 0. Returns
  1914.         1 for success, undef for failure.
  1915. %fx
  1916. &fx(NUM,X,Y)
  1917.         peforms OS_Byte call NUM with the given X and Y 
  1918.         values. Returns an integer whose bottom byte is
  1919.         R1, second byte R2, third byte 0 or 1 as carry was
  1920.         clear or set, and fourth byte 0.
  1921.  
  1922.  
  1923.         
  1924.  
  1925.